import request from '@/axios'
import { SysComponentDetailVo, SysComponentEditQo, SysComponentListVo, SysComponentSearchQo } from './types'
import { BaseDeleteQo } from '@/base/api/BaseQo'
import { KeyLabelValueVo } from '@/base/api/KeyLabelValueVo'

export const sysComponentPageApi = (data: SysComponentSearchQo): Promise<IResponse<Array<SysComponentListVo>>> => {
  return request.post({ url: '/sysComponent/page.adw', data })
}

export const sysComponentDetailApi = (id: number): Promise<IResponse<SysComponentDetailVo>> => {
  const data = { id }
  return request.post({
    url: '/sysComponent/detail.adw',
    data
  })
}

export const sysComponentAddApi = (data: SysComponentEditQo): Promise<IResponse<number>> => {
  return request.post({ url: '/sysComponent/add.adw', data })
}

export const sysComponentUpdateApi = (data: SysComponentEditQo): Promise<IResponse<void>> => {
  return request.post({ url: '/sysComponent/update.adw', data })
}

export const sysComponentDeleteApi = (data: BaseDeleteQo): Promise<IResponse<void>> => {
  return request.post({ url: '/sysComponent/delete.adw', data })
}

export const sysComponentGetByMenuIdApi= (data: SysComponentSearchQo): Promise<IResponse<Array<KeyLabelValueVo>>> => {
  return request.post({ url: '/sysComponent/getByMenuId.adw', data })
}

// [[ OnflowGenerator Range (- selectFunctions -) Start ]]

export const selectSysComponentTitleListApi = (
  data: SysComponentSearchQo
): Promise<IResponse<Array<KeyLabelValueVo>>> => {
  return request.post({ url: '/sysComponent/selectTitleList.adw', data })
}
// [[ OnflowGenerator Range (- selectFunctions -) End ]]
